unit uErrorGetterTools;

interface

uses
  uIErrorGetter, SysUtils;

type
  TErrorGetterTools = class(TObject)
  public
    class procedure checkRaiseLastError(const pvErrorGetter:IInterface);
  end;

implementation

{ TErrorGetterTools }

class procedure TErrorGetterTools.checkRaiseLastError(
  const pvErrorGetter: IInterface);
var
  lvErrorGetter:IErrorGetter;
  lvErrorCode:Integer;
begin
  if pvErrorGetter.QueryInterface(IErrorGetter, lvErrorGetter) = S_OK then
  begin
    lvErrorCode := lvErrorGetter.getLastErrorCode;
    if lvErrorCode <> 0 then
    begin
      if lvErrorCode <> -1 then
      begin
        raise exception.Create('(' + inttoStr(lvErrorCode) + ')' + lvErrorGetter.getLastErrorDesc);
      end else
      begin
        raise exception.Create(lvErrorGetter.getLastErrorDesc);
      end;
    end;
  end;
   
end;

end.
